// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <gtest/gtest.h>
#include <climits>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cantor/parser/parser.h>
#include <cantor/utility/json_reader.h>
#include <tests/config.h>

namespace cantor::parser {
    void check_node_info(Node *node, const nlohmann::ordered_json &result);

    inline void check_stmt_node_info(StmtNode *stmt, const nlohmann::ordered_json &result) {
        check_node_info(stmt, result);
        ASSERT_EQ(StmtType_Name(stmt->stmt_type), result["stmt_type"].get<std::string>());
    }

    inline void check_expr_node_info(DispatchExpr *expr, const nlohmann::ordered_json &result) {
        check_node_info(expr, result);
        ASSERT_EQ(ExprNodeType_Name(expr->expr_type), result["expr_type"].get<std::string>());
    }

    void check_constant_expr_node_info(ConstantExpr *expr, const nlohmann::ordered_json &result);

    void check_var_assign(const VarAssign *assign, const nlohmann::ordered_json &json_var);

    void check_range_var(RangeVar *expr, const nlohmann::ordered_json &result);

    void check_type_stmt(TypeStmt *stmt, const nlohmann::ordered_json &result);

    void check_parse(ParseError e, const nlohmann::ordered_json &result);

    void check_parse(ParseError e, const std::string &errmsg, const nlohmann::ordered_json &result);
} // namespace cantor::parser
